const express = require('express');

const bodyParser = require('body-parser');

const multer = require('multer');

const fs = require('fs');
const app = express();
const form = multer();
const cookieParser = require("cookie-parser");
const template = require('./template.js')
const mongoose = require('mongoose')
mongoose.Promise = Promise;
mongoose.connect('mongodb://localhost/mi')
const db = mongoose.connection;
db.on('error',function(err){
	console.log('数据库连接失败',err)
})
db.on('open',function(err){
	console.log('数据库连接成功')
})
const User = mongoose.model('users',{
	phone:String,
	password:String
})



app.use(bodyParser.urlencoded({ extended: true }))
app.use(cookieParser())

app.use(express.static('www'));
// const template = require('art-template');
template.config('Cache', false)
app.engine('.html', template.__express)
app.set('view engine', 'html')

app.use(require('./routers/index.js'))
app.use(require('./routers/log,reg.js'))



app.get('', function(req, res){
  console.log('这是根目录');
})

app.listen(3000, function(){
  console.log('服务器正常起动');
})
